<template>
  <div>
    <h2>正在测试选项式api的vuex的辅助函数</h2>
    <p v-color2:background="'#aa1'">状态使用：{{ $store.getters.doubleN }}</p>
    <p>状态使用：{{ n }}</p>
    <p>状态使用：{{ uName }}</p>
    <input type="button" value="+1" @click="changeN">
    <input type="button" value="修改" @click="change">
  </div>
</template>

<script>
import {mapState, mapMutations} from "vuex";

export default {
  computed:{
    ...mapState({
      n: state=>state.n,
      uName: state=>state.user.uName
    })
  },
  methods:{
    ...mapMutations({
      changeN: "changeN",
      change_uName: "user/change_uName"
    }),
    change(){
      this.change_uName("李四");
    }
  },
  mounted(){
    console.log(this.$store);
  }
}
</script>